package org.jason.mapmaker.server.repository;

import org.jason.mapmaker.shared.exceptions.RepositoryException;

import java.io.Serializable;

/**
 * @param <T>   type of object being operated on by extensions of the interface
 * @author Jason Ferguson
 */
public interface GenericRepository<T> {

    /**
     * Persist/save an object
     * 
     * @param object    object to persist
     * @return          persisted object
     */
    void persist(T object) throws RepositoryException;

    /**
     * Remove/delete an object
     *
     * @param object    object to remove
     */
    void remove(T object) throws RepositoryException;

    /**
     * Return an object by its unique identifier. Returns a serializable since the GAE datastore doesn't necessarily
     * return an int unless configured to do so.
     *
     * @param uniqueIdentifer   unique identifer of the object to return
     * @return      the object with the given identifier
     */
    T getById(Serializable uniqueIdentifer);
}
